// pages/driver/news/news.js
const handler = require("../../../utils/function.js");
var app = getApp(),
  api = require("../../../api.js");
Page({
  /**
   * 页面的初始数据
   */
  data: {
    img: handler.userImg,
    page:1,
    data: [
      // {
      //   create_time:"2018-11-03 12:48:36",
      //   id:1073,
      //   msg:'您的"帮我买"订单已成功取消，订单编号：2018110216540426504042,感谢您的参与。"',
      //   title:"修改订单"
      // },
      // {
      //   create_time: "2018-11-03 12:48:36",
      //   id: 1073,
      //   msg: '您的"帮我买"订单已成功取消，订单编号：2018110216540426504042,感谢您的参与。"',
      //   title: "系统消息"
      // },
    ]
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    // 获取优惠券
    if (options.uid) {
      app.shareCouponsMessage(options.uid)
    }
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    this.list()
  },
  // 获取列表信息
  list() {
    let that = this;
    var page = that.data.page;
    wx.showLoading();
    app.request({
      url: api.message.getmessage,
      method: 'post',
      data: {
        page: page,
        is_user:1
      },
      success: function (data) {
        var list = that.data.data;
        var data = data.data.data;
        // console.log(list,data,'22222222222222222')
        for (var i = 0; i < data.length; i++) {
          list.push(data[i])
        }
        that.setData({
          data: list
        });
        wx.hideLoading()
      }
    })
  },
  //下拉刷新
  onReachBottom: function (e) {
    console.log(e);
    var { page } = this.data;
    page++;
    this.setData({ page });
    this.list();
  },
  // 用户分享
  onShareAppMessage: function () {
    let title = app.shareAppMessage().title;
    let imageUrl = app.shareAppMessage().imageUrl;
    let desc = app.shareAppMessage().desc;
    let path = app.shareAppMessage().path;
    console.log(app.shareAppMessage())
    return {
      title: title,
      imageUrl: imageUrl,
      desc: desc,
      path: path,
    }
  },
})